package com.drcoffee.drcoffeemall.controller;

import com.drcoffee.drcoffeemall.entry.Result;
import com.drcoffee.drcoffeemall.service.FileService;
import com.drcoffee.drcoffeemall.util.FileUploadDownloadUtil;
import com.drcoffee.drcoffeemall.util.OSSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/file")
public class FileController {
    @Autowired
    FileUploadDownloadUtil fileUploadDownloadUtil;

    @Autowired
    FileService fileService;
    @Autowired
    OSSUtil ossUtil;

    /*
     * 上传图片
     * */
    @PostMapping("/uploadImage")
    public Result uploadImage(@RequestParam("file") MultipartFile file,
                              @RequestParam("file_name") String file_name, Integer type) {
        return fileService.uploadImage(file, file_name, type);
    }

    /*
     * 上传多个文件
     * */
    @PostMapping("/uploadFileList")
    public Result uploadFileList(@RequestParam("files") MultipartFile[] files) {
        return fileService.uploadFileList(files);
    }
}
